package control;

import java.util.List;
import java.util.Map;

import service.FansService;

import com.opensymphony.xwork2.ActionContext;
import com.opensymphony.xwork2.ActionSupport;

import domain.FanUsers;
import domain.User;

public class FansAction extends ActionSupport {
	private User user;
	private FansService fansService;
	private int fanedId;
	
	public FansService getFansService() {
		return fansService;
	}


	public void setFansService(FansService fansService) {
		this.fansService = fansService;
	}


	public User getUser() {
		return user;
	}


	public void setUser(User user) {
		this.user = user;
	}


	public String insertFans(){
		int fanId = user.getId();
		Map session = ActionContext.getContext().getSession();
		String acc = (String) session.get("acc");
		fansService.insertFans(acc,fanId);
//		ServletActionContext.getRequest().
		return ActionSupport.SUCCESS;
	}
	
	public String showFans(){
		Map session = ActionContext.getContext().getSession();
		String acc = (String) session.get("acc");
		List<FanUsers> fans = fansService.showFans(acc);
		Map request = (Map)	ActionContext.getContext().get("request");
		request.put("fans", fans);
		return ActionSupport.SUCCESS;
	}
	
	public String deleteFaned(){
//		System.out.println("我的数字"+fanedId);
		fansService.deleteFaned(fanedId);
		return ActionSupport.SUCCESS;
	}
	
	public String showFaned(){
		Map session = ActionContext.getContext().getSession();
		String acc = (String) session.get("acc");
		List<FanUsers> fans = fansService.showFaned(acc);
		Map request = (Map)	ActionContext.getContext().get("request");
		request.put("fans", fans);
		return ActionSupport.SUCCESS;
	}


	public int getFanedId() {
		return fanedId;
	}


	public void setFanedId(int fanedId) {
		this.fanedId = fanedId;
	}
}
